home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16571 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: ix.netcom.com!news
  2. From: andy0756@ix.netcom.com (Andy Connors)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: ostream & streambuf inheritance
  5. Date: 11 Apr 1996 02:12:01 GMT
  6. Organization: Netcom
  7. Message-ID: <4khpph$enc@dfw-ixnews8.ix.netcom.com>
  8. References: <4jobd7$h0e$3@mhafc.production.compuserve.com>
  9. NNTP-Posting-Host: irv-ca15-21.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-NETCOM-Date: Wed Apr 10  9:12:01 PM CDT 1996
  13. X-Newsreader: WinVN 0.99.7
  14.  
  15. In article <4jobd7$h0e$3@mhafc.production.compuserve.com>, 
  16. 100443.2074@CompuServe.COM writes...
  17. >
  18. >Hi all,
  19. >1) Is there a FAQ?
  20. >2) I am trying to derive from streambuf to create an ostream like 
  21. >class for output to a DOS graphics screen, using the Borland 
  22. >graphics functions. The problem is, my steambuf::overflow 
  23. >overload works fine, but it is not getting called when I flush 
  24. >the stream:
  25. >class graphstream : public ostream
  26. >{
  27. >
  28. >-- 
  29. >Cygnus Instruments Ltd        Ultrasonic NDT Equipment
  30. >   30 Prince of Wales Rd, Dorchester, Dorset DT1 1PW            
  31. >   England    
  32. >Tel +44 (0)1305 265533        Fax +44 (0)1305 269960
  33.  
  34.  
  35. Peter,
  36.  
  37. This is correct behavior.  The streambuf::sync() override is what gets called 
  38. when you flush the stream.  overflow() gets called when the stream object tries 
  39. to put a character (given by the argument to overflow()) into the streambuf, 
  40. but is unable to because the streambuf is full.  overflow() and sync() 
  41. generally send the characters to their destination (they might both call the 
  42. same function to do this), but overflow() should do the additional task of 
  43. placing the character passed as argument into the streambuf, or sending it to 
  44. the destination as well - otherwise, you will lose this one character.
  45.  
  46. Andy Connors
  47.  
  48.